package com.uphone.kingmall.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.SizeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.bean.GoodsListBean;
import com.uphone.kingmall.utils.GlideUtils;

import java.util.List;

/**
 * <pre>
 *     author : 孙增艳
 *     e-mail : sunzengyan@outlook.com
 *     time   : 2019/2/28
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class RvRecommendGoodsAdapter extends BaseQuickAdapter<GoodsListBean.DataBean, BaseViewHolder> {

    private final Context context;

    public RvRecommendGoodsAdapter(Context context, @Nullable List<GoodsListBean.DataBean> data) {
        super(R.layout.kingmall_item_rv_recommend_goods, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsListBean.DataBean item) {
        ImageView imageView = helper.getView(R.id.iv_goods_image);
        helper.setText(R.id.tv_price, "¥" + item.getGoodsPrice())
                .setText(R.id.tv_name, item.getGoodsName())
                .setText(R.id.tv_xiaoliang, "月销" + item.getGoodsSaleNum());
        GlideUtils.getInstance().loadCornerImage(mContext, item.getGoodsMainImg(), SizeUtils.dp2px(2), imageView);
    }
}
